/*
 * AY 2014/15 Semester 1 IS2103 Assignment Part2
 * Matric. No.:    A0102330H
 * Name:           Cui Lin
 */
package ejb;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

/**
 *
 * @author cuilin
 */
@Entity
public class StudentEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String matricNumber;
    private String name;
    private String password;
    private String email;
    @ManyToMany(mappedBy="students")
    private Set<ModuleEntity> modules;
    
    @OneToMany(cascade = {CascadeType.PERSIST})
    private Set<AppealEntity> appeals;
    
    @ManyToMany(mappedBy="students")
    private Set<TutorialEntity> tutorials;

    
    public void create(String matricNumber, String name, String password, String email) {
        this.matricNumber = matricNumber;
        this.name = name;
        this.password = password;
        this.email = email;
    }
    
    public void addAppealEntity(AppealEntity appeal){
        if(null == appeals){
            appeals = new HashSet<AppealEntity>();
        }
        appeals.add(appeal);
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getMatricNumber() {
        return matricNumber;
    }

    public void setMatricNumber(String matricNumber) {
        this.matricNumber = matricNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Set<ModuleEntity> getModules() {
        return modules;
    }

    public void setModules(Set<ModuleEntity> modules) {
        this.modules = modules;
    }

    public Set<AppealEntity> getAppeals() {
        return appeals;
    }

    public void setAppeals(Set<AppealEntity> appeals) {
        this.appeals = appeals;
    }

    public Set<TutorialEntity> getTutorials() {
        return tutorials;
    }

    public void setTutorials(Set<TutorialEntity> tutorials) {
        this.tutorials = tutorials;
    }



}
